<!DOCTYPE html>
<!--[if IE 9]>         <html class="no-js lt-ie10" lang="en"> <![endif]-->
<!--[if gt IE 9]><!-->
<html class="no-js" lang="en">
	<!--<![endif]-->

	<head>
		<meta charset="utf-8">

		<title>通知池——问卷调查系统</title>

		<meta name="description" content="AppUI is a Web App Bootstrap Admin Template created by pixelcave and published on Themeforest">
		<meta name="author" content="pixelcave">
		<meta name="robots" content="noindex, nofollow">

		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

		<!-- Icons -->
		<!-- The following icons can be replaced with your own, they are used by desktop and mobile browsers -->
		<link rel="shortcut icon" href="img/favicon.png">
		<link rel="apple-touch-icon" href="img/icon57.png" sizes="57x57">
		<link rel="apple-touch-icon" href="img/icon72.png" sizes="72x72">
		<link rel="apple-touch-icon" href="img/icon76.png" sizes="76x76">
		<link rel="apple-touch-icon" href="img/icon114.png" sizes="114x114">
		<link rel="apple-touch-icon" href="img/icon120.png" sizes="120x120">
		<link rel="apple-touch-icon" href="img/icon144.png" sizes="144x144">
		<link rel="apple-touch-icon" href="img/icon152.png" sizes="152x152">
		<link rel="apple-touch-icon" href="img/icon180.png" sizes="180x180">
		<!-- END Icons -->

		<!-- Stylesheets -->
		<!-- Bootstrap is included in its original form, unaltered -->
		<link rel="stylesheet" href="css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="css/daterangepicker.css" />

		<!-- Related styles of various icon packs and plugins -->
		<link rel="stylesheet" href="css/plugins.css">
		<link rel="stylesheet" href="css/page.css"/>
		<link rel="stylesheet" href="css/laypage.css">
		<!-- The main stylesheet of this template. All Bootstrap overwrites are defined in here -->
		<link rel="stylesheet" href="css/main.css">

		<!-- Include a specific file here from css/themes/ folder to alter the default theme of the template -->

		<!-- The themes stylesheet of this template (for using specific theme color in individual elements - must included last) -->
		<link rel="stylesheet" href="css/themes/amethyst.css">
		<!-- END Stylesheets -->

		<!-- Modernizr (browser feature detection library) -->
		<script src="js/vendor/modernizr-3.3.1.min.js"></script>
	</head>

	<body>
		<!-- Page Wrapper -->
		<!-- In the PHP version you can set the following options from inc/config file -->
		<!--
            Available classes:

            'page-loading'      enables page preloader
        -->
		<div id="page-wrapper" class="page-loading">
			<!-- Preloader -->
			<!-- Preloader functionality (initialized in js/app.js) - pageLoading() -->
			<!-- Used only if page preloader enabled from inc/config (PHP version) or the class 'page-loading' is added in #page-wrapper element (HTML version) -->
			<div class="preloader">
				<div class="inner">
					<!-- Animation spinner for all modern browsers -->
					<div class="preloader-spinner themed-background hidden-lt-ie10"></div>

					<!-- Text for IE9 -->
					<h3 class="text-primary visible-lt-ie10"><strong>Loading..</strong></h3>
				</div>
			</div>
			<!-- END Preloader -->

			<!-- Page Container -->
			<!-- In the PHP version you can set the following options from inc/config file -->
			<!--
                Available #page-container classes:

                'sidebar-light'                                 for a light main sidebar (You can add it along with any other class)

                'sidebar-visible-lg-mini'                       main sidebar condensed - Mini Navigation (> 991px)
                'sidebar-visible-lg-full'                       main sidebar full - Full Navigation (> 991px)

                'sidebar-alt-visible-lg'                        alternative sidebar visible by default (> 991px) (You can add it along with any other class)

                'header-fixed-top'                              has to be added only if the class 'navbar-fixed-top' was added on header.navbar
                'header-fixed-bottom'                           has to be added only if the class 'navbar-fixed-bottom' was added on header.navbar

                'fixed-width'                                   for a fixed width layout (can only be used with a static header/main sidebar layout)

                'enable-cookies'                                enables cookies for remembering active color theme when changed from the sidebar links (You can add it along with any other class)
            -->
			<div id="page-container" class="header-fixed-top sidebar-visible-lg-full sidebar-light">
				<!-- Alternative Sidebar -->
				<div id="sidebar-alt" tabindex="-1" aria-hidden="true">
					<!-- Toggle Alternative Sidebar Button (visible only in static layout) -->
					<a href="javascript:void(0)" id="sidebar-alt-close" onclick="App.sidebar('toggle-sidebar-alt');"><i class="fa fa-times"></i></a>
				</div>
				<!-- END Alternative Sidebar -->

				<!-- Main Sidebar -->
				<div id="sidebar">
					<!-- Sidebar Brand -->
					<div id="sidebar-brand" class="themed-background">
						<a href="" class="sidebar-title">
							<i class="fa fa-cube"></i> <span class="sidebar-nav-mini-hide"><strong>问道</strong></span>
						</a>
					</div>
					<!-- END Sidebar Brand -->

					<!-- Wrapper for scrolling functionality -->
					<div id="sidebar-scroll">
						<!-- Sidebar Content -->
						<div class="sidebar-content">
							<!-- Sidebar Navigation -->
							<ul class="sidebar-nav">
								<li>
									<a href="questionnaire.html"><i class="gi gi-compass sidebar-nav-icon"></i><span class="sidebar-nav-mini-hide">问卷</span></a>
								</li>
								<li  >
									<a href="survey.html"><i class="fa fa-rocket sidebar-nav-icon"></i><span class="sidebar-nav-mini-hide">调查</span></a>
								</li>
								<li class="active">
									<a href="sendmsg.html"><i class="gi gi-compass sidebar-nav-icon"></i><span class="sidebar-nav-mini-hide">通知池</span></a>
								</li>
							</ul>
							<!-- END Sidebar Navigation -->
						</div>
						<!-- END Sidebar Content -->
					</div>
					<!-- END Wrapper for scrolling functionality -->
					<div style="position: absolute; bottom: 4%;margin: 0 4%;">
						<a href="http://qure.zjgsu.edu.cn/ghc/organize/login.html" style="text-decoration: underline;color: gray;">人员管理系统</a>
						<a href="#modal-info" data-toggle="modal"  style="color: gray;text-decoration: underline;">联系我们</a>
					
					</div>
				</div>
				<!-- END Main Sidebar -->

				<!-- Main Container -->
				<div id="main-container">
					<!-- Header -->
					<!-- In the PHP version you can set the following options from inc/config file -->
					<!--
                        Available header.navbar classes:

                        'navbar-default'            for the default light header
                        'navbar-inverse'            for an alternative dark header

                        'navbar-fixed-top'          for a top fixed header (fixed main sidebar with scroll will be auto initialized, functionality can be found in js/app.js - handleSidebar())
                            'header-fixed-top'      has to be added on #page-container only if the class 'navbar-fixed-top' was added

                        'navbar-fixed-bottom'       for a bottom fixed header (fixed main sidebar with scroll will be auto initialized, functionality can be found in js/app.js - handleSidebar()))
                            'header-fixed-bottom'   has to be added on #page-container only if the class 'navbar-fixed-bottom' was added
                    -->
					<header class="navbar navbar-inverse navbar-fixed-top">
						<!-- Left Header Navigation -->
						<ul class="nav navbar-nav-custom">
							<!-- Main Sidebar Toggle Button -->
							<li>
								<a href="javascript:void(0)" onclick="App.sidebar('toggle-sidebar');this.blur();">
									<i class="fa fa-ellipsis-v fa-fw animation-fadeInRight" id="sidebar-toggle-mini"></i>
									<i class="fa fa-bars fa-fw animation-fadeInRight" id="sidebar-toggle-full"></i>
								</a>
							</li>
							<!-- END Main Sidebar Toggle Button -->

							<!-- Header Link -->
							<li class="hidden-xs animation-fadeInQuick">
								<a href=""><strong>通知池</strong></a>
							</li>
							<!-- END Header Link -->
						</ul>
						<!-- END Left Header Navigation -->

						<!-- Right Header Navigation -->
						<ul class="nav navbar-nav-custom pull-right">
							<!-- User Dropdown -->
							<li class="dropdown">
								<span> </span>
								<a onclick="logout()" class="dropdown-toggle" data-toggle="dropdown">
									注销
								</a>
							</li>
								<!-- END User Dropdown -->
						</ul>
						<!-- END Right Header Navigation -->
					</header>
					<!-- END Header -->

					<!-- Page content -->
					<div id="page-content">
						<!-- Tickets Header -->
						<div class="content-header">
							<div class="row">
								<div class="col-sm-6">
									
								</div>
								<div class="col-sm-3 col-sm-offset-3 hidden-xs">
									<div class="header-section">
										<div class="input-group">
											<input type="text" id="input-search-survey" name="example-input1-group2" class="form-control"  placeholder="搜   索" style="text-align: center";>
											
											<span class="input-group-btn">
                                                <button type="button" class="btn btn-effect-ripple btn-primary"><i class="fa fa-search"></i></button>
                                            </span>
										</div>
									</div>
								</div>
							</div>
						</div>
						<!-- END Tickets Header -->

						<!-- Tickets Content -->
						<div class="row">
								<div class="block full" id="msg-none" style="width:96%;margin: auto;text-align: center;color:slategray;">当前列表为空</div>
								<!-- Menu Block -->
								<div class="block full hidden" id="msg-exit" style="width: 96%;margin:auto;">
									<button type="button" onclick="gotodelete()" class="btn btn-effect-ripple btn-danger" style="margin-left: 7%;margin-top: 2%;">批量删除</button>
									<button type="button" onclick="sendallmsg()" class="btn btn-effect-ripple btn-primary"  style="margin-top: 2%;float: right;margin-right: 3%;">全部通知</button>
								 	<table class="table table-bordered table-striped" id="example-datatable" style="margin-top: 1%;margin-left: 7%;width: 90%;">
												<thead>
													<tr>
														<th style="height: 20%;width: 10%; text-align: center; font-size: 2rem;"><input style="width: 20px;height: 20px;" id="clickall" type="checkbox"/></th>
										 	 	 		<th style="height: 20%;width: 20%; text-align: left; font-size: 2rem;">调查</th>
										 	 	 		<th style="height: 20%;width: 10%; text-align: left; font-size: 2rem;">工号</th>
										 	 	 		<th style="height: 20%;width: 15%; text-align: left;font-size: 2rem;">姓名</th>
										 	 	 		<th style="height: 20%;width:15%;text-align: left;font-size: 2rem;">手机号码</th>
										 	 	 		<th style="height: 20%;width:15%;text-align:left;font-size: 2rem;">短信</th>
										 	 	 		</tr>
												</thead>
												<tbody id="tab_list"  class="table table-bordered table-striped"></tbody>
								<!-- END Menu Block -->
								<!-- delete Modal -->
								<div id="modal-delete" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
									<div class="modal-dialog">
										<div class="modal-content">
											<div class="modal-header">
												<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
												<h3 class="modal-title"><strong>提示</strong></h3>
											</div>
											<div class="modal-body">
												是否删除所选人员？
											</div>
											<div class="modal-footer">
												<button type="button" class="btn btn-effect-ripple btn-primary" onclick="deletenumber()">确定</button>
												<button type="button" class="btn btn-effect-ripple btn-danger" data-dismiss="modal">取消</button>
											</div>
										</div>
									</div>
								</div>
								<!-- END delete Modal -->
							  	<div id="modal-sendmsg" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
									<div class="modal-dialog">
										<div class="modal-content">
											<div class="modal-header">
												<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
												<h3 class="modal-title"><strong>提示</strong></h3>
											</div>
											<div class="modal-body">
												是否发送通知给所有人员？
											</div>
											<div class="modal-footer">
												<button type="button" class="btn btn-effect-ripple btn-primary" onclick="sendMsg()">确定</button>
												<button type="button" class="btn btn-effect-ripple btn-danger" data-dismiss="modal">取消</button>
											</div>
										</div>
									</div>
								</div>
								</table>
							<div id='layui'style="padding: 0 0 20% 0;margin-left: 7%;margin-right: 2%;"></div>
						</div>
						<div id="modal-info" class="modal" tabindex="-1" role="dialog" aria-hidden="true" style="z-index: 2000;">
									<div class="modal-dialog">
										<div class="modal-content">
										<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
										<h3 class="modal-title"><strong>维护人员信息：</strong></h3>
									</div>
									<div class="modal-body">
										<p>手机号：18758263422（543422）</p>
										<p>微 信：F_10086_</p>
										<p>Q Q ：1390415732</p>
									</div>
									<div class="modal-footer">
										<button type="button" class="btn btn-effect-ripple btn-primary" data-dismiss="modal">确定</button>
									</div>
								</div>
							</div>
						</div>
						</div>
						<!-- END Tickets Content -->
					</div>
					<!-- END Page Content -->
				</div>
				<!-- END Main Container -->
			</div>
			<!-- END Page Container -->
		</div>
		<!-- END Page Wrapper -->

		<!-- jQuery, Bootstrap, jQuery plugins and Custom JS code -->
		<script src="js/vendor/jquery-2.2.4.min.js"></script>
		<script src="js/vendor/bootstrap.min.js"></script>
		<script src="js/plugins.js"></script>
		<script src="js/app.js"></script>
		<script src="js/lay/modules/laypage.js"></script>
		<script src="js/layui.js"></script>
		<script src="js/daterangepicker.js"></script>
		<script src="js/moment.js"></script>
		<script src="js/layui.all.js"></script>
		<!-- Load and execute javascript code used only in this page -->
		<script src="js/pages/readyTickets.js"></script>
		<script>
			//url
			var ip;
			var configJson='js/confing.json';
			var checked=[];
			var checkedSet=[];
			var allchecked =[];
			$(function() {
				$.getJSON(configJson,function(data){
				ip=data.urlip;
				identi()
				getlist('','')
				for(var i=0;i<15;i++)
				{
					checked[i]=false;
				}
				});
			});
			function logout(){
				$.ajax({
					type:"get",
					url:ip+"/logout",
					data:{},
					async:true,
					dataType: "json",
					xhrFields: {withCredentials: true},
      				crossDomain:true,
      				success:function(res)
      				{
      					 if(!res.code){
      						window.location.replace("login.html")
							window.history.forward();
      					 }
      				}
				});	
			}
			//判断是否登录
			function identi()
			{
				$.ajax({
     				type: "get",
   					url: ip+"/user/type",
  					data:{
  						
  					},
    				async: true,
    				dataType: "json",
     				xhrFields: {withCredentials: true},
    				crossDomain:true,
    				success: function(res) {
    					console.log("sssss")
    					console.log(res)
						if(res.code==-1)
						{
							 window.location.replace("login.html")
							 window.history.forward(1);
						}
    				},
    				async:false
     			});
			}
			var total,retotal;
			function getlist(pageconf,keyword){
				if(!pageconf){
					pageconf={};
					pageconf.pageSize=15;
					pageconf.currentPage=1;
				}	
				$.ajax({
					type:"get",
					url:ip+"/url/getPool",
					data:{
						page:pageconf.currentPage,
						size:pageconf.pageSize,
						word:keyword
					},
					async:true,
					dataType: "json",
					xhrFields: {withCredentials: true},
      				crossDomain:true,
      				success:function(res)
      				{
      					 if(!res.code){
      					 	if(typeof res.data !='string'){
      					 		if($("#msg-exit").hasClass("hidden"))
      					 		{
      					 			$("#msg-exit").removeClass("hidden")
      					 		}
      					 		if(!$("#msg-none").hasClass("hidden"))
      					 		{
      					 			$("#msg-none").addClass("hidden")
      					 		}
      					 	if(!retotal){
      					 	retotal=res.data.total;
      					 	}
      					 		total=res.data.total;
      					 		dataSet=res.data.datas;
      					 		getPage(pageconf,dataSet,keyword)
      					 	}else{
      					 		if($("#msg-none").hasClass("hidden")){
      					 			$("#msg-none").removeClass("hidden");
      					 		}
								if(!$("#msg-exit").hasClass("hidden"))
								{
									$("#msg-exit").addClass("hidden");
								}
      					 	}
      					 }
      				},
				});	
			}
			
			function gotodelete(){
				$("#modal-delete").modal("toggle")
			}
			
			function getPage(pageconf,data,word)
			{
				layui.use(['laypage','layer'],function(){
					var laypage=layui.laypage;
						
					laypage.render({
						elem:'layui',
						count:total,
						skin:'#7c62ad',
						curr:pageconf.currentPage,
						limit:pageconf.pageSize,
						skip:true,
						first:"首页",
						last:"尾页",
						layout:['count','skip', 'next', 'prev'],
						jump:function(obj,first){
							page=obj.curr;
							limit=obj.limit;
							if(!first){
								 pageconf.currentPage=obj.curr;
								 pageconf.pageSize=obj.limit;
								 getlist(pageconf,word);
							}
						}
						 
						
					});
					fillTable(data,(pageconf.currentPage-1)*pageconf.pageSize);
				});
			}
			
			function fillTable(data,num)
			{
				var info='';
				$.each(data, function(index,obj) {
					var i=index;
					index=index+num+1;
					info += "<tr class='column center'><td class='column' style=' text-align: center; font-size: 2rem;'>"+"<input style='width: 20px;height: 20px;'  id='addcheck' name='addcheck' type='checkbox'"+(checked[i]? "checked   ":" ") +"value='" + obj.id + "'/>"+"</td><td class='column'>"+obj.survey+"</td><td class='column'>" + obj.nickName + "</td><td class='column'>" + obj.name + "</td><td class='column'>"+obj.phoneNumbr+"</td><td class='column'>"+obj.status+"</td></tr>"; 
				});	
				$("#tab_list").html(info);
			}
			$('#example-datatable').on("change", ":checkbox", function() {
				console.log($(this));
				if($(this).is(':checked')) {
					if($(this).val().length==24){
					checkedSet.push($(this).val());
					}
				} else {
					var index = checkedSet.indexOf($(this).val());
					if(index > -1) {
						checkedSet.splice(index, 1);
					}
				}
				console.log(checkedSet);
			});
			
			function deletenumber(){
				$.ajax({
					type:"post",
					url:ip+'/url/clear',
					data: JSON.stringify({
						ids:checkedSet
					}),
					 
					dataType: "json",
					contentType: "application/json",
					xhrFields: {withCredentials: true},
      				crossDomain:true,
      				success:function(res)
      				{
      					 if(!res.code){
      					 	$("#modal-delete").modal("toggle");
      					  	$(".layui-laypage-btn").click();
      					 }
      				},
      				async:true,
				});	
			}
			function getallsendid(str){
				if(allchecked.length){
					allchecked=[];
				}
				$.ajax({
					type: "get",
					url: ip + '/url/getPool',
					data: {
						"page":1,
						"size":retotal,
						"word":str
					},
					dataType: "json",
					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						if(res.code == 0) {
							 $.each(res.data.datas, function(index, value) {
								 allchecked.push(value.id);
							});
							checkedSet=allchecked;
						}
					},
					async:false,
				});
			}
			
			$("#clickall").on('click',function(){
				if(this.checked){
					checkedSet=[];
					getallsendid($("#input-search-survey").val());
					$(this).attr('checked','checked')
					$("input[name='addcheck']").each(function(){
						this.checked=true;
					});
					for(var i=0;i<15;i++)
					{
						checked[i]=true;
					}
				}else{
					$(this).removeAttr('checked')
					$("input[name='addcheck']").each(function(){
						this.checked=false;
					});
					for(var i=0;i<9;i++)
					{
						checked[i]=false;
					}
					checkedSet=[];
				}
			});
			
			$('#input-search-survey').bind('input propertychange', function() {
    			getlist('',$("#input-search-survey").val())
  			});
			function sendallmsg(){
				$("#modal-sendmsg").modal("toggle")
				getallsendid('');
				
			}
			
			function sendMsg(){
				console.log("lahghh")
				$.ajax({
					type: "post",
					url: ip + '/url/inform',
					data:JSON.stringify({
						ids: checkedSet
					}),
					dataType: "json",
					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						if(res.code == 0) {
							location.reload();
						}
						
					},
					async: true
				});
			}
			
			
			
			
			
			
			
		</script>
	</body>

</html>